package com.liao.seckill.util;


import org.apache.commons.codec.digest.DigestUtils;

/**
 * @author lzp
 * @version 1.0
 * lzpnb!
 */
public class MD5Util {

    public static String md5(String src){
        return DigestUtils.md5Hex(src);
    }

    private static final String SALT = "abcdefgh";

    public static String inputPassToMidPass(String inputPass){
        System.out.println("SALT.charAt(0) -> " + SALT.charAt(0));
        System.out.println("SALT.charAt(6) -> " + SALT.charAt(6));
        String str = SALT.charAt(0) + inputPass + SALT.charAt(6);
        return md5(str);
    }

    public static String midPassToDBPass(String midPass,String salt){
        System.out.println("SALT.charAt(1) -> " + SALT.charAt(1));
        System.out.println("SALT.charAt(5) -> " + SALT.charAt(5));
        String str = salt.charAt(1) + midPass + salt.charAt(5);
        return md5(str);
    }

    public static String inputPassToDBPass(String inputPass,String salt){
        String midPass = inputPassToMidPass(inputPass);
        return midPassToDBPass(midPass,salt);
    }


}
